<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.48">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #0024f8}
span.s3 {color: #001bb9}
span.s4 {color: #000000}
span.s5 {color: #ad140d}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>ArrayMin<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b></span><b>detect the smallest value (and its position) in an array of UGens</b></p>
<p class="p2"><br></p>
<p class="p3"><b># val, index = ArrayMin.ar(array)</b></p>
<p class="p3"><b># val, index = ArrayMin.kr(array)</b></p>
<p class="p2"><br></p>
<p class="p3">Finds the minimum value in an <a href="SC://Array"><span class="s2">Array</span></a> of <a href="SC://UGen"><span class="s2">UGen</span></a>s, and outputs the <i>value</i> and the <i>index</i>.</p>
<p class="p2"><br></p>
<p class="p3">This is for use in a <a href="SC://SynthDef"><span class="s2">SynthDef</span></a>. If you simply need to find out which is the minimum in an array of numbers, use the <b><i>minIndex</i></b> and/or <b><i>minItem</i></b> methods defined for any <a href="SC://Collection"><span class="s2">Collection</span></a>.</p>
<p class="p2"><br></p>
<p class="p3">See also: ArrayMax, <a href="../../../Extensions/MCLDUGens/Help/BufMax.html"><span class="s2">BufMax</span></a></p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p3"><b>Example</b></p>
<p class="p2"><br></p>
<p class="p3">Here we generate a three-channel signal containing some simple test curves, and analyse it to generate a plot:</p>
<p class="p2"><br></p>
<p class="p4">s.boot;</p>
<p class="p4">(</p>
<p class="p4">{</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="s3">var</span> son, val, index;</p>
<p class="p4"><span class="Apple-tab-span">	</span>son = [</p>
<p class="p5"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><span class="s3">Line</span><span class="s4">.ar(10, 1, 0.5),<span class="Apple-converted-space">  </span></span>// a linear descent in half a second</p>
<p class="p5"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><span class="s3">XLine</span><span class="s4">.ar(1, 10, 1), <span class="Apple-converted-space">  </span></span>// an exponential ascent in one second</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">DC</span>.ar(2)<span class="Apple-converted-space">              </span><span class="s5">// a constant</span></p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>];</p>
<p class="p4"><span class="Apple-tab-span">	</span># val, index = <span class="s3">ArrayMin</span>.ar(son);</p>
<p class="p4"><span class="Apple-tab-span">	</span>[val, index]</p>
<p class="p4">}.plot(1, minval: <span class="s3">nil</span>, maxval: <span class="s3">nil</span>);</p>
<p class="p4">)</p>
<p class="p2"><br></p>
<p class="p3">Here we use the operation as an audio effect:</p>
<p class="p2"><br></p>
<p class="p4">(</p>
<p class="p4">x = {</p>
<p class="p5"><span class="s4"><span class="Apple-tab-span">	</span></span>// A collection of different tones:</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="s3">var</span> son = <span class="s3">SinOsc</span>.ar((100, 100.3 .. 110));</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="s3">var</span> val = <span class="s3">ArrayMin</span>.ar(son).at(0);</p>
<p class="p5"><span class="s4"><span class="Apple-tab-span">	</span>val = </span><span class="s3">LeakDC</span><span class="s4">.ar(val); </span>// the operation tends to induce DC offset</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="s3">Pan2</span>.ar(val)</p>
<p class="p4">}.play</p>
<p class="p4">)</p>
<p class="p4">x.free</p>
</body>
</html>
